<div id="wrapper">
    <!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
    <h1><a href="#"><span>&nbsp;</span></a>Tài khoản: <?php echo $this->objLogin->member_username ; ?></h1>
    <br />
    <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet -->
    <ul id="mainNav">
            <li><a href="#" class="active">TRANG QUẢN TRỊ</a></li> <!-- Use the "active" class for the active menu item  -->
            <li><a href="<?php echo $this->rootUrl ?>/default" >TRANG CHỦ</a></li>
            <li><a href="#">THIẾT LẬP</a></li>
            <li class="logout"><a href="<?php echo $this->rootUrl ?>/admin/index/logout">THOÁT</a></li>
    </ul>
    <!-- // #end mainNav -->

    <div id="containerHolder">
        <div id="container">
            <div id="sidebar">
                <ul class="sideNav">
                    <li><a href="#">Quản lý danh mục</a></li>
                    <li><a href="<?php echo $this->rootUrl ?>/admin/index/news"  >Quản lý tin bài</a></li>
                    <li><a href="<?php echo $this->rootUrl ?>/admin/index/index" class="active">Quản lý sản phẩm</a></li>
                    <li><a href="#">Giới thiệu</a></li>
                    <li><a href="#">Thông tin liên hệ</a></li>
                    <li><a href="#">Quản trị hệ thống</a></li>
                    <li><a href="#">Ngôn ngữ</a></li>
                </ul>
                <!-- // .sideNav -->
            </div>    
            <!-- // #sidebar -->
            <!-- h2 stays for breadcrumbs -->
            <h2><a href="#">Trang quản trị</a> &raquo; <a href="<?php echo $this->rootUrl ?>/admin/index/index" class="active">Quản lý sản phẩm</a></h2>
            <div id="main">
                <h3>Danh sách sản phẩm</h3>
                <table cellpadding="0" cellspacing="0">
                    <?php
                        if(is_array($aryProduct = $this->aryProduct)) {
                            $flag = 0;$aryCategory = array();
                            foreach($aryProduct as $key=>$product) : 
                                if($flag == 0 || $flag != $product['product_category_id']) { 
                                    $aryCategory[] = array('product_category_id'=>$product['product_category_id']
                                                           ,'product_category_name'=>$product['product_category_name'] 
                                                           ); ?>
                                    <tr style="font-weight:bold;" >
                                        <td><?php echo $product['product_category_name'];?></td>
                                        <td class="action"><a href="#" class="view">Chi tiết</a><a href="#" class="edit">Sửa</a><a href="#" class="delete">Xóa</a></td>
                                    </tr>
                    <?php        
                                    $flag = $product['product_category_id'];
                                }
                                if($product['product_id'] > 0 ) { ?>
                                    <tr <?php if($key%2==1) { ?> class="odd" <?php } ?> >
                                        <td><?php echo $product['product_name'];?></td>
                                        <td class="action"><a href="#" class="view">Chi tiết</a><a href="<?php echo $this->rootUrl ?>/admin/index/index/prdId/<?php echo $product['product_id'] ; ?>" class="edit">Sửa</a><a onclick="Admin.deleteProduct(<?php echo $product['product_id'] ; ?>);" class="delete">Xóa</a></td>
                                    </tr>    
                    <?php 
                                }
                            endforeach;
                        } ?>               
                </table>
                <form action="save" class="jNice" method="post"  enctype="multipart/form-data" id="frmAddEditProduct" name="frmAddEditProduct" >
                <?php $aryInfo = $this->aryInfo ; ?>
                <h3>Sản phẩm </h3>
                <fieldset>
                        <p><label>Tên sản phẩm:</label><input name="product_name" type="text" class="text-long" value="<?php if(isset($aryInfo['product_name'])) { echo $aryInfo['product_name'] ; } ?>"  /></p>
                        <input name="product_id" type="hidden" value="<?php echo $aryInfo['product_id'] ; ?>" />
                        <!--<p><label>Sample label:</label><input type="text" class="text-medium" /><input type="text" class="text-small" /><input type="text" class="text-small" /></p>-->
                        <p><label>Phân loại sản phẩm</label>
                            <select name="product_cate_id" >
                                <!--<option value="0">&nbsp;</option>-->
                            <?php
                                if(is_array($aryCategory)) {
                                    foreach($aryCategory as $cate) : ?>
                                    <option value="<?php echo $cate['product_category_id'] ;?>" <?php if(isset($aryInfo['product_cate_id']) && $aryInfo['product_cate_id'] == $cate['product_category_id'] ) { echo "selected"; } ?> ><?php echo $cate['product_category_name'] ;?></option>
                            <?php            
                                    endforeach;
                                }  ?>
                            </select>
                        </p>
                        <p><label>Mô tả:</label><input name="product_description" type="text" class="text-long" value="<?php if(isset($aryInfo['product_description'])) { echo $aryInfo['product_description'] ; } ?>" /></p>
                        <p><label>Chi tiết:</label><textarea id="product_detail"  name="product_detail" rows="1" cols="1"><?php if(isset($aryInfo['product_detail'])) { echo $aryInfo['product_detail'] ; } ?></textarea></p>
                        <p><label>Ảnh sản phẩm:</label><input type="file" id="product_image" name="product_image" class="text-long" /></p>
                        <p><label>Thứ tự hiển thị:</label><input name="product_order" type="text" class="text-long"  value="<?php if(isset($aryInfo['product_order'])) { echo $aryInfo['product_order'] ; } ?>" /></p>
                        <p><label  class="cpointer" for="product_top" >Hiển thị trang chủ:<input id="product_top" name="product_top" type="checkbox"  value="1" <?php if(isset($aryInfo['product_top']) && $aryInfo['product_top'] == 1) { echo "checked" ; } ; ?> /></label></p>
                        <input class="c-pointer" type="button" onclick="Admin.saveProduct();" value="Cập nhật" />
                </fieldset>
                </form>
            </div>
            <div class="clear"></div>
        </div>
        <!-- // #container -->
    </div>	
    <!-- // #containerHolder -->
    <p id="footer">Nếu quí khách hàng cần tư vấn, giải đáp thắc mắc. <a href="mailto:tncdt2k48@gmail.com"> Hãy liên hệ ngay với chúng tôi</a></p>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        Admin.getHtmlEditor('product_detail'); 
    });
</script>